package cn.cyb.server.controller;

import cn.cyb.server.domain.AjaxResult;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.constraints.Pattern;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Validated
@Tag(name = "TestController", description = "测试")
public class TestController {

    @GetMapping("/test")
    public AjaxResult test() {
        String s = "hello " + System.currentTimeMillis();
        return AjaxResult.success(s);
    }

    /**
     * 参数校验测试
     *
     * @param name 参数长度5到16位
     * @return
     */
    @GetMapping("/test2")
    public AjaxResult test2(@Pattern(regexp = "^\\S{5,16}$", message = "name参数长度为5到16位") String name) {
        String s = "hello " + System.currentTimeMillis();
        return AjaxResult.success(s);
    }
}
